
const {Article} = require('../../model/article');
module.exports = async (req, res) => {
  req.app.locals.current = 'article';
  const id = req.query.id;
  // 修改操作
  if(id) {
    const article = await Article.findOne({_id: id});
    res.render('admin/article-edit', {
      message: req.query.message,
      article,
      link: '/admin/article-modify?id=' + id,
      button: '修改'
    });
  }else {
    res.render('admin/article-edit', {
      message: req.query.message,
      link: '/admin/article-edit',
      button: '添加'
    });
  }
}